//
//  NSObject+objName.m
//  NSRunTimeDemo
//
//  Created by CPZX010 on 16/9/22.
//  Copyright © 2016年 谢昆鹏. All rights reserved.
//

#import "NSObject+objName.h"
#import <objc/message.h>


#pragma mark    寄生
@interface ObjBlock : NSObject
@property (nonatomic, copy) void(^deallocBlock)(void);

@end

@implementation ObjBlock

- (void)dealloc {
    if (self.deallocBlock) {
        self.deallocBlock();
    }
}

@end







@implementation NSObject (objName)

- (void)setObjcName:(NSString *)objcName {
    /**
     *  参数1:为哪个类目类别添加属性
     *  参数2:关联属性的key, 通过此key获取
     *  参数3:关联的value
     *  参数4:关联策略
     *  KVC资源
     */
    objc_setAssociatedObject(self, @"objcName", objcName, OBJC_ASSOCIATION_COPY);
}


- (NSString *)objcName {
    return objc_getAssociatedObject(self, @"objcName");
}

///为所有对象添加一个释放时触发的block
- (void)triggerDellocBlock:(void(^)(void))block {
    
    
    
    
    

    
    
    
    
    
}


@end
